import { Controller, Get, Post, Body, Param, Delete, UseGuards } from '@nestjs/common';
import { ReportsService } from './reports.service';
import { CreateReportDto } from './dto/create-report.dto';
import { TokenGuard } from '../../common/guards/token.guard';
import { RolesGuard } from '../../common/guards/roles.guard';
import { Roles } from '../../common/decorators/roles.decorator';

@Controller('reports')
@UseGuards(TokenGuard, RolesGuard)
export class ReportsController {
  constructor(private readonly reportsService: ReportsService) {}

  @Post()
  @Roles('admin', 'devops')
  generate(@Body() createReportDto: CreateReportDto) {
    return this.reportsService.generate(createReportDto);
  }

  @Get()
  @Roles('admin', 'devops', 'viewer')
  findAll() {
    return this.reportsService.findAll();
  }

  @Get(':id')
  @Roles('admin', 'devops', 'viewer')
  findOne(@Param('id') id: string) {
    return this.reportsService.findOne(+id);
  }

  @Delete(':id')
  @Roles('admin', 'devops')
  remove(@Param('id') id: string) {
    return this.reportsService.delete(+id);
  }
} 